const Sequelize = require('sequelize');
const db = require('./database/db');

//数据模型
const sequelize = new Sequelize(db.database, db.user, db.password, {
    host: db.host,
    dialect: 'mysql',
    pool: {
        max: 5,
        min: 0,
        idle: 30000
    }
});

const Model = [];

//登陆用户模型
Model.User = sequelize.define('user', {
    Id: {
        type: Sequelize.INTEGER(50),
        primaryKey: true
    },
    UserName: Sequelize.STRING(100),
    UserPass: Sequelize.STRING(100),
    Permission: Sequelize.STRING(100)
}, {
        timestamps: false
    });

//登陆信息
Model.LoginInfo = sequelize.define('logininfo', {
    Id: {
        type: Sequelize.INTEGER(50),
        primaryKey: true
    },
    UserId: Sequelize.STRING(100),
    LoginDate: Sequelize.BIGINT,
    Remark: Sequelize.STRING(100)
}, {
        timestamps: false
    });

//会员模型
Model.Customer = sequelize.define('customer', {
    Id: {
        type: Sequelize.INTEGER(50),
        primaryKey: true
    },
    CustomerNum: Sequelize.STRING(100),
    CustomerName: Sequelize.STRING(100),
    CustomerPhone: Sequelize.STRING(100),
    CustomerLevel: Sequelize.STRING(100),
    HandleDate: Sequelize.BIGINT,
    CreateDate: Sequelize.BIGINT,
    UpdateDate: Sequelize.BIGINT,
}, {
        timestamps: false
    })

//会员消费模型
Model.Consume = sequelize.define('customer_consume', {
    Id: {
        type: Sequelize.INTEGER(50),
        primaryKey: true
    },
    Customer_Id: Sequelize.INTEGER(100),
    Customer_Name: Sequelize.STRING(100),
    Amount: Sequelize.STRING(100),
    AmountType: Sequelize.STRING(100),
    AmountDate: Sequelize.STRING(100)
}, {
        timestamps: false
    })


//次数卡模型
Model.Card = sequelize.define('card', {
    Id: {
        type: Sequelize.INTEGER(50),
        primaryKey: true
    },
    CardNum: Sequelize.STRING(100),
    CardName: Sequelize.STRING(100),
    AllFrequency: Sequelize.STRING(100),
    UsedFrequency: Sequelize.STRING(100),
    SurplusFrequency: Sequelize.STRING(100),
    HandleDate: Sequelize.BIGINT,
    CreateDate: Sequelize.BIGINT,
    UpdateDate: Sequelize.BIGINT
}, {
        timestamps: false
    })

//次数卡消费记录模型
Model.CardConsume = sequelize.define('card_consume', {
    Id: {
        type: Sequelize.INTEGER(50),
        primaryKey: true
    },
    CardNum: Sequelize.STRING(100),
    CardName: Sequelize.STRING(100),
    CardAmount: Sequelize.STRING(100),
    AmountDate: Sequelize.BIGINT
}, {
        timestamps: false
    })

module.exports = Model;
